package com.atguigu.spzx.manager.service.impl.product;

import com.atguigu.spzx.manager.mapper.product.ProductSpecMapper;
import com.atguigu.spzx.manager.service.product.ProductSpecService;
import com.atguigu.spzx.model.entity.product.ProductSpec;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductSpecServiceImpl implements ProductSpecService {
    @Resource
    ProductSpecMapper productSpecMapper;
    @Override
    public void save(ProductSpec productSpec) {
        productSpecMapper.save(productSpec);
    }

    @Override
    public void deleteById(Long id) {
        productSpecMapper.deleteById(id);
    }

    @Override
    public ProductSpec getById(Long id) {
        return productSpecMapper.getById(id);
    }

    @Override
    public void update(ProductSpec productSpec) {
        productSpecMapper.update(productSpec);
    }

    @Override
    public PageInfo<ProductSpec> page(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<ProductSpec> list = productSpecMapper.findPage();
        return new PageInfo<>(list);
    }

    @Override
    public List<ProductSpec> findAll() {
        return productSpecMapper.findPage();
    }
}
